import 'package:flutter/material.dart';
import 'package:flutter_filereader/flutter_filereader.dart';
import 'package:open_file/open_file.dart';
//import 'package:share/share.dart';
import 'package:shared_preferences/shared_preferences.dart';

class FileReaderPage extends StatefulWidget {
  final String? filePath;

  FileReaderPage({Key: Key, this.filePath});

  @override
  _FileReaderPageState createState() => _FileReaderPageState();
}

class _FileReaderPageState extends State<FileReaderPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("文件预览"),
        actions: <Widget>[
          ElevatedButton(
              onPressed: () => OpenFile.open(widget.filePath),
              child: Icon(
                Icons.open_in_new,
                color: Colors.white,
              ))
        ],
      ),
      body: FileReaderView(
        filePath: widget.filePath,
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.share),
        onPressed: () async {
          //OpenFile.open(widget.filePath);
          // Share.shareFiles(
          //   [widget.filePath!],
          // );
        },
      ),
    );
  }
}
